package com.heartunderblade.rpc.Registry;

import com.heartunderblade.rpc.RpcPojo.ServiceMetaInfo;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class RegistryServiceCache {
    ConcurrentHashMap<String, List<ServiceMetaInfo>> map  = new ConcurrentHashMap<String, List<ServiceMetaInfo>>();
    /**
     * 写缓存
     * @param newServiceCache
     */
    public void writeCache(String serviceKey, List<ServiceMetaInfo> newServiceCache){
        map.put(serviceKey,newServiceCache);
    }

    /**
     * 读缓存
     * @return
     */
    List<ServiceMetaInfo> readCache(String serviceKey){
        return map.get(serviceKey);
    }
    /**
     * 清空缓存
     */
    void clearCache() {
        this.map = null;
    }
}
